/**
 * 
 */
package com.witframework.baseapp.common.enterprise;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;
import org.javalid.annotations.core.ValidateDefinition;
import org.javalid.annotations.validation.NotEmpty;
import org.springmodules.validation.bean.conf.loader.annotation.handler.Length;

import com.witframework.core.annotations.Wit;

/**
 * @author wuxinyang
 * Jun 18, 2009 2:14:49 PM
 * 
 */

@Entity @Table(name="AD_ORGTYPE")
@Wit(cnname="组织类",description="组织类型",cnproperty="name")
@ValidateDefinition
public class OrganizationType{	
	
	private String id ;
	/** 
	 * Organization
	 * Legal with accounting
	 * Generic
	 * Legal without accounting
	 */
	@Wit(cnname="名称",description="类型名称")
	private String name;	
	@Wit(cnname="备注",description="说明")
	private String description;		
	@Wit(cnname="是否缺省",description="缺省的类型")
	private String isdefault="N";	
	@Wit(cnname="法人实体？",description="是否法人实体？")
	private String islegalentity="N";
	@Wit(cnname="商业实体",description="是否商业实体")
	private String isbusinessunit="Y";
	@Wit(cnname="是否允许汇报？",description="保留字段",unused=true)
	private String istransactionsallowed="N";	
	@Wit(cnname="独立核算？",description="保留字段",unused=true)
	private String isacctlegalentity="Y";
	
	
	private List<Organization> orgs;

	@Column(length=32)@Id
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}	
	@Column(length=60) @Length(max=60) @NotEmpty
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	
	@Column(length=255) @Length(max=255) @NotEmpty
	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.description = description;
	}

	@Column(length=1) @NotEmpty
	public String getIsdefault() {
		if(isdefault==null)
			return "N";
		return isdefault;
	}
	public void setIsdefault(String isdefault) {
		this.isdefault = isdefault;
	}

	
	@Column(length=1) @NotEmpty
	public String getIslegalentity() {	
		if(islegalentity==null)
			return "N";
		return islegalentity;
	}
	public void setIslegalentity(String islegalentity) {
		this.islegalentity = islegalentity;
	}

	
	@Column(length=1) @Length(max=1) @NotEmpty
	public String getIsbusinessunit() {
		if(isbusinessunit==null)
			return "Y";
		return isbusinessunit;
	}
	public void setIsbusinessunit(String isbusinessunit) {
		this.isbusinessunit = isbusinessunit;
	}

	
	@Column(length=60) @Length(max=60) @NotEmpty
	public String getIstransactionsallowed() {
		return istransactionsallowed;
	}
	public void setIstransactionsallowed(String istransactionsallowed) {
		this.istransactionsallowed = istransactionsallowed;
	}
	
	
	@Column(length=60) @Length(max=60) @NotEmpty
	public String getIsacctlegalentity() {
		return isacctlegalentity;
	}

	public void setIsacctlegalentity(String isacctlegalentity) {
		this.isacctlegalentity = isacctlegalentity;
	}

	@OneToMany(mappedBy="organizationType")@LazyCollection(value=LazyCollectionOption.FALSE)
	public List<Organization> getOrgs() {
		return orgs;
	}

	public void setOrgs(List<Organization> orgs) {
		this.orgs = orgs;
	}
	
}
